#pragma once
#include "cinclude.hpp"
#include "cppinclude.hpp"

//#define MORE_DEBUG_OUTPUT

const int MMAP_CONTENT_LENGTH = 409600 + 1;

//2020 02 28写下：不要在结构体中使用sem_t*，会出现内存对齐导致的The futex facility returned an unexpected error code may happen错误？？
//为了避免这个问题，准备直接用裸sem_t*，准备2020 02 29解决

//set because I use sem_t* in struct, if not set, The futex facility returned an unexpected error code may happen
#pragma pack(1)
/*
 * struct_sem_parent_manager, only one sem_t
 */
//struct struct_sem_parent_manager{
//public:
//	sem_t* psem_managerShutdown;    			//lock for managerShutdown
//	struct_sem_parent_manager(): psem_managerShutdown(nullptr) {;};
//};

/*
 * struct_val_parent_manager, only one bool
 */
struct struct_val_parent_manager{
public:
	bool isShutdown;                  //when set to true, shutdown!
	struct_val_parent_manager(): isShutdown(false) {;};
};

/*
 * struct_sem_manager_worker, only one sem_t
 */
//struct struct_sem_manager_worker{
//public:
//	sem_t* psem_workerTaskEnd;    //lock for workerTaskEnd, only when worker operate on a task end can it be post by worker
//	struct_sem_manager_worker(): psem_workerTaskEnd(nullptr) {;};
//};

/*
 * struct_val_manager_worker, only one char[409600]
 */
struct struct_val_manager_worker{
public:
	char content[MMAP_CONTENT_LENGTH];                  //when set to true, shutdown!
	struct_val_manager_worker() {
		memset(content, 0, MMAP_CONTENT_LENGTH*sizeof(char));
	};
};

//set back
#pragma pack()

/*
 * struct for workers, with abort inside initializer!
 */
//struct struct_workers{
//public:
//	bool isShutdown;                  //when set to true, shutdown!
//	struct_mIntArray workers;         //stores all childs producer process ids, for manager process to use
//	
//	struct_workers();        //dump
//};
